package com.maoning.gulimallcart.config;

import com.maoning.gulimallcart.interceptor.CartInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @ClassName : GulimallWebConfig
 * @Author : Administrator
 * @Date: 2022/4/8 13:43
 *
 * 拦截器的应用:必须注入到配置类中,记住配置类的名字:WebMvcConfigurer
 * 注入拦截器的时候直接new放进去就可以了
 */
@Configuration
public class GulimallWebConfig implements WebMvcConfigurer {


    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new CartInterceptor()).addPathPatterns("/**");
    }
}
